package cn.hx.controller;

import cn.hx.entity.User;
import cn.hx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
public class UserDocController {
    @Autowired
    UserService userService;
//    员工档案
    @GetMapping("searchUserDoc")
    public String getSearchUserDoc(Model model){
        model.addAttribute("users",userService.selectAll());
        return "searchUserDoc";
    }

//    员工薪资
    @GetMapping("searchUserWages")
    public String getSearchUserWages(Model model){
        model.addAttribute("users",userService.selectAll());
        return "searchUserWages";
    }
//    修改员工薪资
    @PostMapping("updateUserWages/{id}")
    public String postUpdateUserWages(@PathVariable Integer id, User user){
        user.setId(id);
        userService.update(user);
        return "redirect:/searchUserWages";
    }


    public String getString(){
        User user = new User();
        userService.queryByPage(user, PageRequest.of(1,20));
        return null;
    }

}
